package secretaryGUI;

import secretary.defineSemester;

import com.sun.rowset.CachedRowSetImpl;

import flexibility.userData;
import guiCode.secretaryScreenCode;
import basic.ClientConsole;

public class viewCourses {
	
private userData coursesData = new userData();
private updateUpperTableEntries UUTE = new updateUpperTableEntries();
private defineSemester ds = new defineSemester();
private secretaryScreenCode ssc;
	/**
	 * this will show the courses table in the upper table
	 * */
	public void view(ClientConsole secretaryConnection,CachedRowSetImpl crs, createSecretaryWindow csw, secretaryScreenCode code){
		
		ssc = code;

		if(ssc.getEditMode()==10){
			switch(ssc.getSemesterForEdit()){
			case 0: //this is the current semester
				coursesData.deleteAll();
				coursesData.addData(260);
				coursesData.addData(1);
				coursesData.addData(ds.identify(0, secretaryConnection, crs));
				coursesData.addData(ds.identify(0, secretaryConnection, crs));
				secretaryConnection.acceptMsg(coursesData);
				crs = secretaryConnection.getResults();
				UUTE.update(csw, crs);
				break;
			case 1://this is the next semester
				coursesData.deleteAll();
				coursesData.addData(260);
				coursesData.addData(1);
				coursesData.addData(ds.identify(1, secretaryConnection, crs));
				coursesData.addData(ds.identify(0, secretaryConnection, crs));
				secretaryConnection.acceptMsg(coursesData);
				crs = secretaryConnection.getResults();
				UUTE.update(csw, crs);
				break;
			}
		}
		if(ssc.getEditMode()==6 || ssc.getEditMode()==11){
			//view courses button pressed
			switch(ssc.getSemesterForEdit()){
			case 0: //this is the current semester
				coursesData.deleteAll();
				coursesData.addData(260);
				coursesData.addData(1);
				coursesData.addData(ds.identify(0, secretaryConnection, crs));
				coursesData.addData(ds.identify(0, secretaryConnection, crs));
				secretaryConnection.acceptMsg(coursesData);
				crs = secretaryConnection.getResults();
				UUTE.update(csw, crs);
				break;
			case 1://this is the next semester
				coursesData.deleteAll();
				coursesData.addData(260);
				coursesData.addData(1);
				coursesData.addData(ds.identify(1, secretaryConnection, crs));
				coursesData.addData(ds.identify(0, secretaryConnection, crs));
				secretaryConnection.acceptMsg(coursesData);
				crs = secretaryConnection.getResults();
				UUTE.update(csw, crs);
				break;
			}
		}
			if(ssc.getEditMode()==9){
				switch(ssc.getSemesterForEdit()){
				case 0: //this is the current semester
					coursesData.deleteAll();
					coursesData.addData(259);
					coursesData.addData(1);
					coursesData.addData(ds.identify(0, secretaryConnection, crs));
					secretaryConnection.acceptMsg(coursesData);
					crs = secretaryConnection.getResults();
					UUTE.update(csw, crs);
					break;
				case 1://this is the next semester
					coursesData.deleteAll();
					coursesData.addData(259);
					coursesData.addData(1);
					coursesData.addData(ds.identify(1, secretaryConnection, crs));
					secretaryConnection.acceptMsg(coursesData);
					crs = secretaryConnection.getResults();
					UUTE.update(csw, crs);
					break;
				}
			}
		}
		
		
		
	}

